package com.example.recyclerViewDemo

import android.annotation.SuppressLint
import android.graphics.drawable.Drawable
import android.os.Bundle
import android.widget.LinearLayout
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.LayoutManager
import com.example.recyclerViewDemo.databinding.MainActivityBinding



/**
 * @Author Xzh
 * @Date 2024/12/16
 * @Description
 */
@SuppressLint("UseCompatLoadingForDrawables")
class MainActivity : AppCompatActivity(){



    private val imageList : List<Drawable> by lazy {
        listOf(
            this.resources.getDrawable(R.drawable.bk,null),
            this.resources.getDrawable(R.drawable.image1,null),
            this.resources.getDrawable(R.drawable.image2,null),
            this.resources.getDrawable(R.drawable.image3,null),
            this.resources.getDrawable(R.drawable.image4,null),
            this.resources.getDrawable(R.drawable.image5,null),
        )
    }

    private val mBinding : MainActivityBinding by lazy {
        MainActivityBinding.inflate(layoutInflater)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(mBinding.root)

        initView()
    }

    private fun initView() {
//        mBinding.recycler.layoutManager = LinearLayoutManager(this,RecyclerView.HORIZONTAL,false)
        mBinding.recycler.layoutManager = MyLayoutManager()
        mBinding.recycler.adapter = MyAdapter(imageList)
    }
}